package com.fcscs.cservice.ws.endpoint;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

import com.fcscs.cservice.ws.schema.common.AuthorizedRequest;
import com.fcscs.cservice.ws.schema.commonconfigservice.GetCommonConfigResponse;
import com.fcscs.ecms.service.ECMSCommonConfigManager;

/**
 * @author pvttinh
 * 
 */

@Endpoint
public class CommonConfigServiceEndpoint {

	@Autowired
	private ECMSCommonConfigManager commonConfigMgr;
	
	/**
	 * 
	 * @param req
	 * @return
	 */
	@PayloadRoot(localPart = CServiceWSConstants.GET_COMMON_CONFIG_RQ, namespace = CServiceWSConstants.COMMON_CONFIG_SERVICE_NAMESPACE_URI)
	@ResponsePayload
	public GetCommonConfigResponse getCommonConfigList(@RequestPayload AuthorizedRequest req) {

		GetCommonConfigResponse resp = new GetCommonConfigResponse();
		try{
			resp.setCommonConfigInfoList(commonConfigMgr.getCommonConfigList(req.getOrgId(), req.getPropId()));
			resp.setSuccess(true);
		}catch (Exception e) {
			// TODO: handle exception
			resp.setSuccess(false);
			resp.setErrorMessage(e.getMessage());
		}
		
		return resp;
	}
}
